package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.PmsProductCategoryAttributeRelation;
import com.itheima.mapper.PmsProductCategoryAttributeRelationMapper;
import com.itheima.service.db.PmsProductCategoryAttributeRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsProductCategoryAttributeRelationServiceImpl implements PmsProductCategoryAttributeRelationService {
    @Autowired
    PmsProductCategoryAttributeRelationMapper ppcarMapper;

    @Override
    public void save(PmsProductCategoryAttributeRelation ppcar) {
        ppcarMapper.insert(ppcar);
    }

    @Override
    public List<PmsProductCategoryAttributeRelation> findByCategoryId(Long productCategoryId) {
        LambdaQueryWrapper<PmsProductCategoryAttributeRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(PmsProductCategoryAttributeRelation::getProductCategoryId, productCategoryId);
        return ppcarMapper.selectList(lqw);
    }

    @Override
    public void deleteByCategoryId(Long categoryId) {
        LambdaQueryWrapper<PmsProductCategoryAttributeRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(PmsProductCategoryAttributeRelation::getProductCategoryId, categoryId);
        ppcarMapper.delete(lqw);
    }
}
